package cn.iocoder.yudao.module.pay.splitting.controller.app;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.module.pay.splitting.service.core.CoreSplittingMerchantService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 前端控制器
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/17
 */
@Tag(name = "用户 APP - 分账回调")
@RestController
@RequestMapping("/pay/splitting/notify")
@Slf4j
public class AppSplittingNotifyController {
    @Resource
    private CoreSplittingMerchantService coreSplittingMerchantService;

    @RequestMapping(value = "/register", method = {RequestMethod.GET, RequestMethod.POST})
    @Operation(summary = "回调地址", description = "第三方分账商户注册审核结果异步通知")
    @PermitAll // 回调无需登录限制
    @ApiAccessLog(responseEnable = true)
    public String register(@RequestParam(required = false) Map<String, String> params, @RequestBody(required = false) String body, @RequestHeader(required = false) Map<String, String> headers) {
        return coreSplittingMerchantService.register(params, body, headers);
    }

    @RequestMapping(value = "/complete", method = {RequestMethod.GET, RequestMethod.POST})
    @Operation(summary = "回调地址", description = "第三方分账担保交易异步分账异步通知")
    @PermitAll // 回调无需登录限制
    @ApiAccessLog(responseEnable = true)
    public String complete(@RequestParam(required = false) Map<String, String> params, @RequestBody(required = false) String body, @RequestHeader(required = false) Map<String, String> headers) {
        return coreSplittingMerchantService.complete(params, body, headers);
    }

}
